<template>
    <el-dialog :visible.sync="show" width="70%" @click="show = false" class="partmentsDialo">
      <el-form label-width="180px" :model="editForm">
        <el-row>
          <el-col :span="10" style="marginRight:16px">
            <el-form-item label="科室名称" class="tip">
              <el-input class="flex-1" size="small" v-model="editForm.name" auto-complete="off" placeholder="请输入科室名称"></el-input>
            </el-form-item>
            <el-form-item label="房屋使用单价">
              <el-input class="flex-1" size="small" v-model="editForm.house_price" auto-complete="off" placeholder="请输入房屋使用单价"></el-input>
            </el-form-item>
            <el-form-item label="房屋面积">
              <el-input class="flex-1" size="small" v-model="editForm.house_space" auto-complete="off" placeholder="请输入房屋面积" ></el-input>
            </el-form-item>
            <el-form-item label="设备维护费用">
              <el-input class="flex-1" size="small" v-model="editForm.device_maintain" auto-complete="off" placeholder="请输入设备维护费用" ></el-input>
            </el-form-item>
            <el-form-item label="本期可控变动成本">
              <el-input class="flex-1" size="small" v-model="editForm.current_period_controllable_variable_cost" auto-complete="off" placeholder="请输入本期可控变动成本" ></el-input>
            </el-form-item>
            <el-form-item label="基期科内有效收入">
              <el-input class="flex-1" size="small" v-model="editForm.base_department_income" auto-complete="off" placeholder="请输入基期科内有效收入" ></el-input>
            </el-form-item>
            <el-form-item label="基期可控变动成本">
              <el-input class="flex-1" size="small" v-model="editForm.base_period_controllable_variable_cost" auto-complete="off" placeholder="请输入基期可控变动成本" ></el-input>
            </el-form-item>
            <el-form-item label="变动成本控制扣罚比率">
              <el-input class="flex-1" size="small" v-model="editForm.variable_cost_control_deduction_rate" auto-complete="off" placeholder="请输入变动成本控制扣罚比率" ></el-input>
            </el-form-item>
            <el-form-item label="是否参与绩效">
              <el-checkbox v-model="is_performance" :true-label='1' :false-label='0'></el-checkbox>
            </el-form-item>
            <el-form-item label="目标(基期)门诊均例费用">
              <el-input class="flex-1" size="small" v-model="editForm.target_average_cost" auto-complete="off" placeholder="请输入目标(基期)门诊均例费用" ></el-input>
            </el-form-item>
            <el-form-item label="科室基期门急诊人次">
              <el-input class="flex-1" size="small" v-model="editForm.target_patient_count" auto-complete="off" placeholder="请输入科室基期门急诊人次" ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="目标平均住院日">
              <el-input class="flex-1" size="small" v-model="editForm.target_in_hospital_day" auto-complete="off" placeholder="请输入目标平均住院日" ></el-input>
            </el-form-item>
            <el-form-item label="目标出院病人均例费用">
              <el-input class="flex-1" size="small" v-model="editForm.target_average_leave_cost" auto-complete="off" placeholder="请输入目标出院病人均例费用" ></el-input>
            </el-form-item>
            <el-form-item label="目标出院病人均例药品费用">
              <el-input class="flex-1" size="small" v-model="editForm.target_average_drug_cost" auto-complete="off" placeholder="请输入目标出院病人均例药品费用" ></el-input>
            </el-form-item>
            <el-form-item label="目标出院病人均例耗材费用">
              <el-input class="flex-1" size="small" v-model="editForm.target_average_material_cost" auto-complete="off" placeholder="请输入目标出院病人均例耗材费用" ></el-input>
            </el-form-item>
            <el-form-item label="科室基期占床日">
              <el-input class="flex-1" size="small" v-model="editForm.base_use_bed_day" auto-complete="off" placeholder="请输入科室基期占床日" ></el-input>
            </el-form-item>
            <el-form-item label="目标术前待床日">
              <el-input class="flex-1" size="small" v-model="editForm.target_stay_bed_day" auto-complete="off" placeholder="请输入目标术前待床日" ></el-input>
            </el-form-item>
            <el-form-item label="扣罚金额">
              <el-input class="flex-1" size="small" v-model="editForm.punish_amount" auto-complete="off" placeholder="请输入扣罚金额" ></el-input>
            </el-form-item>
            <el-form-item label="奖励金额">
              <el-input class="flex-1" size="small" v-model="editForm.reward_amount" auto-complete="off" placeholder="请输入奖励金额" ></el-input>
            </el-form-item>
            <el-form-item label="点数单价">
              <el-input class="flex-1" size="small" v-model="editForm.point_price" auto-complete="off" placeholder="请输入点数单价" ></el-input>
            </el-form-item>
            <el-form-item label="目标收治率">
              <el-input class="flex-1" size="small" v-model="editForm.target_admission_rate" auto-complete="off" placeholder="请输入目标收治率" ></el-input>
            </el-form-item>
            <el-form-item label="目标手术率">
              <el-input class="flex-1" size="small" v-model="editForm.target_surgery_rate" auto-complete="off" placeholder="请输入目标手术率" ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer">
        <el-button @click="show = false">取 消</el-button>
        <el-button type="primary" @click="submit" :loading="btnLoading">确 定</el-button>
      </div>
    </el-dialog>
</template>

<script>
import { debounce } from "@/utils";

export default {
    props:{
        btnLoading:{
          default:false,
        },
        disabled:{
            default:false,
        },
        editForm:{
            default:()=>({})
        }
    },
    data(){
        return {
          show: false,
          is_performance: 0,
        }
    },
    watch:{
      'editForm.is_performance'(flag){
        this.is_performance = flag || 0
      }
      
    },
    methods:{
        submit: debounce(function (){
          if(this.btnLoading) return
          this.editForm.is_performance  = this.is_performance
          if(!this.editForm.name){
            this.$message({
              type: 'error',
              message: '请输入科室名称!'
            });
            return 
          }
          let editForm = {...this.editForm}
          for(let key in editForm){
            if(!editForm[key] && editForm[key] !== 0){
              delete editForm[key]
            }
          }
          this.is_performance = 0
          this.$emit('submit',editForm)
        },500,true)
    }
}
</script>

<style lang='less'>
.partmentsDialo{
  .el-col-12{
    width: 70%;
  }
  .el-form-item__label{
    display: inline-block;
    white-space: nowrap;
    min-width: 120px;
  }
  .el-form-item__content{
    display: flex;
    .span{
      margin-left: 8px;
      font-size: 12px;
    }
  }
}

</style>